import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "main",
      component: HomeView,
      redirect: "/home",
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("../views/Home/index.vue"),
        },
        {
          path: "/news",
          name: "news",
          component: () => import("../views/News/index.vue"),
        },
        {
          path: "/news/detail/:id",
          name: "newsDetail",
          component: () => import("../views/News/Detail.vue"),
        },
        {
          path: "/news/edit",
          name: "editNews",
          component: () => import("../views/News/EditNews/index.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/works",
          name: "works",
          component: () => import("../views/Works/index.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/works/biographical",
          name: "biographical",
          component: () => import("../views/Works/Biographical/index.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/works/job",
          name: "job",
          component: () => import("../views/Works/Job/index.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/works/apply",
          name: "apply",
          component: () => import("../views/Works/Apply/index.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/things",
          name: "things",
          component: () => import("../views/Things/index.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/things/apply",
          name: "thingsApply",
          component: () => import("../views/Things/Apply.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/things/list",
          name: "thingsList",
          component: () => import("../views/Things/List.vue"),
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/Suggestion",
          name: "Suggestion",
          component: () => import("../views/Suggestion/index.vue"),
          meta: {
            requireAuth: false,
          },
        },
      ],
    },
    {
      path: "/login",
      name: "login",
      component: () => import("../components/login.vue"),
    },
    {
      path: "/register",
      name: "register",
      component: () => import("../components/register.vue"),
    },
  ],
});

export default router;
